package com.zjut.zs.xy.manager;

import java.util.List;

import javax.annotation.Resource;

import com.zjut.an.util.module.PageModule;
import com.zjut.zs.cj.dao.ZsCj;
import com.zjut.zs.user.dao.ZsUser;
import com.zjut.zs.xy.dao.ZsXy;
import com.zjut.zs.xy.dao.ZsXyDAO;


public class ZsXyManager {

	@Resource(name = "ZsXyDAO")
	private ZsXyDAO dao;
	
	public void addData(ZsXy obj) {	
		dao.save(obj);
	}
	
	public void updateData(ZsXy obj) {
		dao.update(obj);
	}
	
	public void deleteData(ZsXy obj) {
		dao.delete(obj);
	}

	public void deleteDatas(List<ZsXy> objlist) {
		for (ZsXy ZsXy : objlist) {
			dao.delete(ZsXy);
		}
	}
	
	public PageModule getDataByInstance (int pageNumber,int pageSize, String sort, String order, ZsXy obj) {
		return dao.findByInstance(pageNumber, pageSize, sort, order, obj);
	}
	
	public List getDatas() {
		return dao.findAll();
	}

	public ZsXy getData(int objId) {
		return dao.findById(objId);
	}

	public ZsXy getDataByUser(ZsUser user) {
		ZsXy obj = new ZsXy();
		obj.setZsUser(user);
		if(this.getDataByInstance(1, 1, null, null, obj).getObjects().size()>0) {
			return (ZsXy)this.getDataByInstance(1, 1, null, null, obj).getObjects().get(0);
		} else{
			return obj;
		}
	}
}
